const {promisify} = require('util');
const {pipeline} = require('stream');
const {createReadStream,createWriteStream} = require('fs');
const {createGzip} = require('zlib');





const compressHtmlFileByGzip = async (sourceFile,destinationFile) => {

    const source = createReadStream(sourceFile);
    const destination = createWriteStream(destinationFile);
    const gzip = createGzip();
    const pipe = promisify(pipeline);
    return await pipe(source,gzip,destination).catch(err => console.error(err));
}

compressHtmlFileByGzip('index.html','index.html.gz');

